package com.example.ribbonconsumer.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.ZoneAvoidanceRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置覆盖默认
 * @date 2019-4-16 23:09:47
 * @author joker
 */
@Configuration
public class MyRibbonConfiguration {

    /**
     * LoadBalanced默认的负载均衡的策略是RandomRule
     * @return RoundRobinRule
     */
    @Bean
    public IRule roundRobbinRule(){
//        return new ZoneAvoidanceRule();
        return new RandomRule();
    }

}
